<template>
	<view>
		<view class="roundcenter">
			<view class="round">
				<view class="avatar">
					<image src="../../static/portrait.png"></image>
				</view>
			</view>
			<view class="formcontent">
				<u-form :model="form" ref="uForm">
					<u-form-item label="姓名" prop="name" required label-width="140" border-bottom>
						<u-input v-model="form.name" placeholder="请输入姓名" />
					</u-form-item>
					<u-form-item label="性别" prop="sex" required label-width="140" border-bottom>
						<u-radio-group v-model="form.sex">
							<u-radio active-color="#ffc92a" v-for="(item, index) in sexList" :key="item.name"
								:name="item.name" :disabled="item.disabled">
								{{ item.name }}
							</u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item label="年龄阶段" prop="age" required label-width="140" border-bottom>
						<u-input v-model="form.age" placeholder="请输入年龄" />
					</u-form-item>
					<u-form-item label="联系方式" prop="tel" len="11" required label-width="140" border-bottom>
						<u-input v-model="form.tel" placeholder="请输入联系方式" />
					</u-form-item>
				</u-form>
			</view>
		</view>
		<view class="organization combg">
			<view class="organizationtitle">
				<image src="../../static/organ.png"></image>
				<text>测评机构</text>
			</view>
			<view class="savebutton" @click="submit">开始测评</view>
			<!-- 			<navigator url="/pages/questions/questions" open-type="navigate">
				
			</navigator> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					name: '',
					age: '',
					tel: '',
					sex: ''
				},
				sexList: [{
						name: '男孩',
						disabled: false
					},
					{
						name: '女孩',
						disabled: false
					}
				],
				rules: {
					name: [{
						required: true,
						message: '请输入姓名',
						trigger: ['change', 'blur']
					}],
					sex: [{
						required: true,
						message: '请选择性别',
						trigger: ['change', 'blur']
					}],
					age: [{
						required: true,
						message: '请输入年龄',
						trigger: ['change', 'blur']
					}],
					tel: [{
							required: true,
							message: '请输入联系方式',
							trigger: ['change', 'blur']
						},
						{
							validator: (rule, value, callback) => {
								return this.$u.test.mobile(value);
							},
							message: '手机号码不正确',
							// 触发器可以同时用blur和change
							trigger: ['change', 'blur'],
						}
					]
				}
			}
		},
		methods: {
			submit() {
				this.$refs.uForm.validate(valid => {
					if (valid) {
						localStorage.setItem("mlaform",JSON.stringify(this.form));
						uni.navigateTo({
							url: '/pages/questions/questions'
						});
						
					} else {
						console.log('验证失败');
					}
				});
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		}
	}
</script>

<style scoped>
	page {
		background-color: #ffc92a;
	}

	.roundcenter {
		width: 686rpx;
		margin: 60rpx auto 0 auto;
		background: #fff;
		box-shadow: 0 40rpx 0 -22rpx rgb(221 138 0 / 23%), 0 -9px 0 0 rgb(105 100 87 / 14%) inset;
		border-radius: 50rpx;
	}

	.round {
		width: 100%;
		height: 124rpx;
		background: url(../../static/roundbg.png) no-repeat 50%/100%;
	}

	.avatar {
		width: 125rpx;
		height: 135rpx;
		border-radius: 50%;
		box-shadow: 0 -9rpx 0 0 rgb(105 100 87 / 14%) inset;
		margin: auto;
	}

	.avatar image {
		width: 125rpx;
		height: 125rpx;
	}

	.formcontent {
		padding: 40rpx;
	}

	.formcontent .label-text span {
		font-size: 26rpx;
	}

	.organization .organizationtitle image {
		width: 32rpx;
		height: 30rpx;
		vertical-align: middle;
		margin-right: 10rpx;
	}

	.organization .organizationtitle text {
		font-size: 28rpx;
		vertical-align: middle;
		color: #857f77;
	}

	.savebutton {
		width: 622rpx;
		line-height: 90rpx;
		color: #594e3f;
		font-size: 32rpx;
		font-weight: 700;
		margin: 70rpx auto;
		text-align: center;
		background: url(../../static/savebtn.png) no-repeat 50%/100%;
	}
</style>
